<template>
	<view>
		<view class="mt-5" v-if="u_loadmore">
			<u-loadmore status="loading" icon-type="circle" />
		</view>
		<view v-else>
			<!-- 商品分类 -->
			<radio-group>
				<view class="rounded-20 m-2 bg-white">
					<label v-for="(item,index) in oneGoods" :key="index" @click="one_goods(item)">
						<view class="d-flex j-sb pl-3 a-center h_110"  >
							<radio color="#fc3939" :value="item.cat_name" :checked="item.cat_id == current" />
							<view class="flex-1 d-flex j-sb a-center h_100 border-bottom">
								<view class="ml-1 font-md">{{item.cat_name}}</view>
							</view>
						</view>
					</label>
				</view>
			</radio-group>
			<!-- 平台分类 -->
			<radio-group >
				<view class="rounded-20 m-2 bg-white" >
					<label v-for="(item,index) in oneClazz" :key="index" @click="one_goods(item)">
						<view class="d-flex j-sb pl-3 a-center h_110">
							<radio :value="item.cat_name" color="#fc3939" :checked="item.cat_id == current" />
							<view class="flex-1 d-flex j-sb a-center h_100 border-bottom">
								<view class="ml-1 font-md">{{item.cat_name}}</view>
							</view>
						</view>
					</label>
				</view>
			</radio-group>
		</view>	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsClazz:[], // 商品分类列表
				oneGoods:[], // 1级商品分类
				
				terraceClazz:[], // 平台分类
				oneClazz:[], // 1级平台分类
				
				tabIndex:0,  // 标识符tab
				goods_cat_id:"" ,// 二级parent_id
				current:"",
				boardList:[],
				User:"",
				
				show_class:'',
				
				u_loadmore:true, // 加载中
			}
		},
		onLoad(e) {
			console.log(e)
			this.current=e.category_id
			this.$H.post("admin/user/userinfo").then(res=>{
				this.User=res.data
				if(this.User.is_merchant){
					console.log("0")
					// 商品分类 merchant merchant
					this.$H.post("admin/merchant/goods/merchant/category").then(res=>{
						this.u_loadmore=false 
						this.goodsClazz=res.data
						this.goodsClazz.filter((item,index)=>{
								return item.icon_show=false,item.iconshow=false
						})
						this.oneGoods=this.goodsClazz.filter((item,index)=>{
							if(e.cat_id==item.parent_id){
								return item
							}
						})
						console.log(this.oneGoods)
					})
				}else{
					console.log("1")
					// 平台分类
					this.$H.post("admin/merchant/goods/category").then(res=>{
						this.u_loadmore=false 
						this.terraceClazz=res.data
						this.terraceClazz.filter((item,index)=>{
								return item.icon_show=false
						})
						
						this.oneClazz=this.terraceClazz.filter((item,index)=>{
							if(e.cat_id==item.parent_id){
								return item
							}
						})
						console.log(this.oneClazz)
					})
				}
			})
		},
		methods: {
			one_goods(item){
				this.current=item.cat_id
				uni.navigateBack({
					delta:2
				})
				var globalData = getApp().globalData.closeLists;
				getApp().globalData.closeLists= item; 
			}
		}
	}
</script>

<style>
</style>
